/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 10-12-14
 * Time: 下午1:36
 * To change this template use File | Settings | File Templates.
 */

ConceptAutoComplete = Ext.extend(Ext.form.ComboBox, {

    // 构造方法
    constructor : function(_config) {
        if (_config == null) {
            _config = {};
        }

        Ext.apply(this, _config);

        // 调用父类的构造方法
        MeshAutoComplete.superclass.constructor.call(this, {
            store: new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: 'concept.action?action=search&highLight=0'
                }),
                /*  fields: [
                 "lh",'lj', 'lm','lmzs'
                 ] ,*/
                reader: new Ext.data.JsonReader({
                    root : 'rows',
                    totalProperty: 'total',
                    id:"id"

                }, [
                    {name: 'dname', mapping: 'dname'} ,
                    {name: 'cname', mapping: 'cname'}

                ]) ,
                // 监听事件
                listeners : {
                    "beforeload":{
                        fn: function (store, obj) {
                            store.baseParams.searchkey = this.getValue();
                        }  ,
                        scope : this
                    } , specialkey:function(field, e) {
                        alert("回车");
                        if (e.getKey() == Ext.EventObject.ENTER) {

                            var myMask = new Ext.LoadMask(Ext.getBody(), {
                                msg: '正在加载,请稍后......',
                                removeMask: true //完成后移除
                            });
                        }
                    }
                }
            }),
            allowBlank : false, // 不允许为空
            displayField:'lh',
            typeAhead: false,
            loadingText: 'Searching...',
            pageSize:15,
            emptyText:"概念词搜索",
            minChars:1,
            autoScroll:false,
            hideTrigger:true,
            tpl: new Ext.XTemplate(
                /*     '<tpl for="."><div class="search-item">',
                 '<h3><span>概念词: {cname}</span></h3><span>主题词:{dname}</span>',
                 '{excerpt}',
                 '</div></tpl>'*/
                    '<tpl for="."><div class="search-item">',
                    '<h3> {cname}</h3><br>{dname}',
                    '{excerpt}',
                    '</div></tpl>'
                    ),

            itemSelector : 'div.search-item',
            onSelect : function(record) { // override default onSelect to do redirect
                this.setValue(record.data.cname);
                this.collapse();
                // new FLZTMeshTreePanel().onMeshTreeSearch();
            }
        })
    }


})
        ;
